 package br.com.caelum.vraptor.dao;

import javax.persistence.NoResultException;

import br.com.caelum.vraptor.entidades.Aluno;

public class AlunoDAO extends GenericJPADAO<Aluno> {
	
	public AlunoDAO(){
		this.persistentClass = Aluno.class;
	}

	public Aluno find(String email, String senha){
		try{
			Aluno n = getEm().createQuery("select a from Aluno a where a.email like :email and a.senha = :senha", Aluno.class)
		   .setParameter("email", email)
		   .setParameter("senha", senha)
		   .getSingleResult();
			return n;
		}
		catch(NoResultException e){
			return null;
		}
	}
}
